package com.itfenghuang.day18_lx;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class A03_zuoye extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        String pt = req.getParameter("username");
        String pd = req.getParameter("password");
//        int i = Integer.parseInt(pd);
//        int i1 = Integer.parseInt(pt);
//        int sum=i+i1;
        int sum=Integer.parseInt(pd)*Integer.parseInt(pt);
        HttpSession ss = req.getSession();
        ss.setAttribute("qqq",sum);
        //resp.sendRedirect("/a3zuoye_1");
        RequestDispatcher re = req.getRequestDispatcher("/a3zuoye_1");
        re.forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
